import React from 'react';
import QueueAnim from 'rc-queue-anim';
import { observer, inject } from 'mobx-react';
import { withRouter, Route } from 'react-router-dom';
import { List, Tools, Switch } from 'weaver-mobile';
import ShareSet from '../shareSet';
import Share from './Share';
const getLabel = Tools.getLabel;

@withRouter
@inject('userCenterStore')
@observer
export default class Setting extends React.Component {
  static defaultProps = {
    prefixCls: 'blog-center-setting'
  }

  componentDidMount() {
    const { userCenterStore:{ settingStore } } = this.props;
    settingStore.getBaseSetting();
  }

  componentWillUnmount() {
    const { userCenterStore:{ settingStore } } = this.props;
    settingStore.settingClear();
  }
  
  render() {
    let { prefixCls, userCenterStore:{ settingStore } } = this.props;
    let { saveBaseSetting, isReceive,allowRequest } = settingStore;
    let pd=(allowRequest=='1' ? false: true);
    return (
      <div className={`${prefixCls}`}>
        <List className={`${prefixCls}-content`}>
          <List.Item

           extra={<Switch checked={isReceive * 1 === 1}  disabled={pd} onChange={v => saveBaseSetting(v)}/>}
          >{getLabel(384478,'接收关注申请')}</List.Item>
          {/* <List.Item 
            arrow='horizontal' 
            onClick={() => this.props.history.push('/userCenter/setting/shareSet')}
          >{getLabel(26945, "分享设置")}</List.Item> */}
        </List>
        <Route 
          key="userCenter-setting-shareSet"
          path="/userCenter/setting/shareSet"
          breadcrumbName="个人中心-微博设置-分享设置"
          render={() => (
            <div className="wm-route-layout" style={{ position: 'fixed' }}>
              <QueueAnim>
                {/* <Share /> */}
                <ShareSet key="shareSet" parentPath="/userCenter/setting/shareSet" />
              </QueueAnim>
            </div>
          )}
        />
      </div>
    )
  }
}